﻿// ***********************************************************************
// Assembly         : Invisionware.API.Amazon
// Author           : Shawn Anderson (sanderson@eye-catcher.com)
// Created          : 01-10-2014
//
// Last Modified By : Shawn Anderson
// Last Modified On : 01-19-2014
// ***********************************************************************
// <copyright file="ItemDataTypes.cs" company="Invisionware">
//     Copyright (c) Invisionware. All rights reserved.
// </copyright>
// <summary></summary>
// ***********************************************************************

using System;
using System.Collections.Generic;

namespace Invisionware.API.Amazon
{
	/// <summary>
	/// Class AwsCommonOptions.
	/// </summary>
	public class AwsCommonOptions
	{
		#region Constructors
		public AwsCommonOptions()
		{
			AwsServiceUrl = "webservices.amazon.com";
			AwsNameSpace = "http://webservices.amazon.com/AWSECommerceService/2011-08-01";

			Service = "AWSECommerceService";
			Version = "2011-08-01";
		}
		#endregion Constructors

		#region Public Properties
		/// <summary>
		/// Specifies the Product Advertising API service. There is only one value for all Product Advertising API operations. 
		/// Valid Value: AWSECommerceService
		/// Required: Yes
		/// </summary>
		/// <value>The service.</value>
		public string Service { get; private set; }

		/// <summary>
		/// An alphanumeric token that uniquely identifies an Associate. This token is the means by which Amazon identifies the Associate to credit for a sale. 
		///	If a request is made without identifying an Associate, Associate fees are not paid by Amazon. If the AssociateTag is included in the CartCreate request, 
		///	the value for AssociateTag is automatically included in the PurchaseURL, which is returned by CartCreate. To obtain an Associate Tag, go to 
		///	https://affiliate-program.amazon.com. For more information, see Associate Tag.
		/// Valid Values: An alphanumeric token distributed by Amazon that uniquely identifies an Associate. Use this value in all requests to receive credit 
		///	for the customer's purchase.
		// Required: Yes
		/// </summary>
		/// <value>The associate tag.</value>
		public string AssociateTag { get; set; }

		/// <summary>
		/// The version of the Product Advertising API software and WSDL to use. By default, the 2011-08-01 version is used. Alternately, specify a 
		///	software version, such as 2011-08-01. For a list of valid version numbers, refer to the Product Advertising API Release Notes. Note that 
		///	the latest version of Product Advertising API is not used by default.
		/// Default: 2011-08-01
		/// Valid Values: Valid WSDL version date, for example, 2011-08-01.
		/// Required: No
		/// </summary>
		/// <value>The version.</value>
		public string Version { get; set; }

		/// <summary>
		/// An alphanumeric token that uniquely identifies a seller. For information about getting an AWS access key ID, see Becoming an Associate.
		/// Valid Value: Access Key ID distributed by Amazon.
		/// Required: Yes
		/// </summary>
		/// <value>The access key identifier.</value>
		public string AccessKeyId { get; set; }

		/// <summary>
		/// Gets or sets the aws access key secret.
		/// </summary>
		/// <value>The aws access key secret.</value>
		public string AccessKeySecret { get; set; }

		/// <summary>
		/// Specifies the format of the content in the response. For example, to transform your Product Advertising API response into HTML, 
		// set ContentType to text/html. 	
		// Required: No
		/// </summary>
		/// <value>The type of the content.</value>
		public string ContentType { get; set; }

		/// <summary>
		/// Specifies the Marketplace Domain where the request will be directed. For more information, see MarketplaceDomain Parameter.
		/// Required: No
		/// </summary>
		/// <value>The marketplace domain.</value>
		public string MarketplaceDomain { get; set; }

		/// <summary>
		/// An optional parameter that can be used to filter search results and offer listings to only include items sold by Amazon. By default, the 
		///	API will return items sold by various merchants including Amazon. Valid values:
		/// Amazon‐Only items sold by Amazon are included in the response.
		/// Required: No
		/// </summary>
		/// <value>The merchant identifier.</value>
		public string MerchantId { get; set; }

		// <summary>
		// Gets or sets the operation.
		// </summary>
		// <value>The operation.</value>
		//public AwsItemOperationTypes? Operation { get; set; }
		/// <summary>
		/// Prevents an operation from executing. Set the Validate parameter to True to test your request without actually executing it. When present, 
		///	Validate must equal True; the default value is False. If a request is not actually executed (Validate=True), only a subset of the errors 
		///	for a request may be returned because some errors (for example, no_exact_matches) are only generated during the execution of a request.
		/// Default: False
		/// Valid Values: True, False
		/// Required: No
		/// </summary>
		/// <value><c>true</c> if validate; otherwise, <c>false</c>.</value>
		public bool? Validate { get; set; }

		/// <summary>
		/// Specifies whether responses are XML-encoded in a single pass or a double pass. By default, XMLEscaping is Single, and Product Advertising 
		///	API responses are encoded only once in XML. For example, if the response data includes an ampersand character (&), the character is returned
		///	in its regular XML encoding (&). If XMLEscaping is Double, the same ampersand character is XML-encoded twice (&amp;). The Double value for 
		///	XMLEscaping is useful in some clients, such as PHP, that do not decode text within XML elements.
		/// Default: Single
		/// Valid Values: Single, Double
		/// </summary>
		/// <value>The XML escaping.</value>
		public AwsXmlEscapingTypes? AwsXmlEscaping { get; set; }

		/// <summary>
		/// Gets or sets the aws service URL.
		/// </summary>
		/// <value>The aws service URL.</value>
		public string AwsServiceUrl { get; set; }

		/// <summary>
		/// Gets or sets the aws name space.
		/// </summary>
		/// <value>The aws name space.</value>
		public string AwsNameSpace { get; set; }
		#endregion Public Properties

		#region Internal Methods
		/// <summary>
		/// Prepares the specified operation.
		/// </summary>
		/// <param name="operation">The operation.</param>
		/// <returns>IDictionary{System.StringSystem.String}.</returns>
		/// <exception cref="System.ArgumentNullException">AssociateTag;AssociateTag Value must be specified</exception>
		internal IDictionary<string, string> Prepare(AwsItemOperationTypes operation)
		{
			if (string.IsNullOrEmpty(AssociateTag))
				throw new ArgumentNullException("AssociateTag", "AssociateTag Value must be specified");

			IDictionary<string, string> r1 = new Dictionary<string, string>();

			r1["Service"] = Service;
			r1["AssociateTag"] = AssociateTag;

			if (!string.IsNullOrEmpty(Version)) r1["Version"] = Version;
			// if (!string.IsNullOrEmpty(AccessKeyId)) r1["AWSAccessKeyId"]
			if (!string.IsNullOrEmpty(ContentType)) r1["ContentType"] = ContentType;
			if (!string.IsNullOrEmpty(MarketplaceDomain)) r1["MarketplaceDomain"] = MarketplaceDomain;
			if (!string.IsNullOrEmpty(MerchantId)) r1["MerchantId"] = MerchantId;

			//if (!Operation.HasValue) throw new ArgumentNullException("Operation Value must be specified");
			r1["Operation"] = operation.ToString();

			if (Validate.HasValue) r1["Validate"] = Validate.Value.ToString();
			if (AwsXmlEscaping.HasValue) r1["XMLEscaping"] = AwsXmlEscaping.Value.ToString();

			return r1;
		}
		#endregion Internal Methods
	}
}
